home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / misc / TCS.lha / TCS / examples / sources / ILBM&Fade.s < prev    next >
Encoding:
Text File  |  2000-04-13  |  4.0 KB  |  131 lines

  1. *******************************************************************************
  2. * ILBM handling and fade in/out example
  3. *******************************************************************************
  4. * INFO    loads a 320x256x8 ILBM to a FullRes screen and then fades it
  5. *    in and out
  6. * NOTE    - optionally you can pass as CLI argument the names of the
  7. *      320x256x8 IFF/ILBMs to load (if not one of those supplied in
  8. *      TCS/examples/pix/, make sure that yours is exactly 320x256x8
  9. *      and that it respects all the restrictions of TCS_LdILBM(),
  10. *      otherwise the program won't execute or the graphics will
  11. *      look bad - not dangerous, anyway!)
  12. *    - LMB to exit anytime
  13. *******************************************************************************
  14.  
  15.     machine    68020
  16.  
  17.     include    INCLUDES:libraries/tcs.i
  18.     include    INCLUDES:libraries/tcs_lib.i
  19.  
  20.  
  21.  
  22. *******************************************************************************
  23. * definitions
  24. *******************************************************************************
  25.  
  26. DSPLWD    =    320    ;our TCS display width and
  27. DSPLHT    =    256    ;height in 140 ns pixels
  28. SCRWD    =    320    ;TCS screen width and
  29. SCRHT    =    256    ;height in pixels
  30. DSPLX0    =    $81*4    ;display start
  31. DSPLY0    =    $2c    ;position (SHRES pixels)
  32. DSPLX1    =    DSPLX0+DSPLWD*4    ;display end
  33. DSPLY1    =    DSPLY0+DSPLHT    ;position (SHRES pixels)
  34. DSPLBRTNS    =    0    ;min brightness
  35. GFXCTXT    =    0
  36. CWBTM    =    0
  37. CWTOP    =    0
  38. CWRT    =    0
  39. CWLF    =    0
  40. VDOMODE    =    TCS_VM_RGBW | TCS_VMf_FullRes ;TCS display video mode
  41.  
  42. ARGSNO    =    1    ;command line arguments no.
  43.  
  44.  
  45.  
  46. *******************************************************************************
  47. * code start
  48. *******************************************************************************
  49.  
  50.     include    /includes/macros.i
  51.     include    /includes/shl_strtup.i
  52.  
  53.  
  54.  
  55. *******************************************************************************
  56. * init
  57. *******************************************************************************
  58.  
  59. _PrgInit    movea.l    CmdLnArgs,a0    ;ILBM filename address
  60.     tst.l    a0
  61.     bne.s    .ld    ;if filename specified...
  62.     lea.l    PicFlNm,a0    ;default ILBM
  63. .ld    movea.l    ([DIAdr.l],TCS_DI_CSAdr.w),a1 ;directly to
  64.     move.l    #SCRWD*SCRHT,d0    ;screen buffer
  65.     CALLTCS    LdILBM    ;load it
  66.     cmpi.l    #TCS_PE_OK,d0    ;success?
  67.     blo.s    .fail    ;if not...
  68.     move.l    d0,ILBMStrcAdr    ;else store its ILBM structure address
  69.     rts        ;& clr ccr.Z to signal success
  70. .fail    move.w    #4,ccr    ;signal error
  71.     rts
  72.  
  73.  
  74.  
  75. *******************************************************************************
  76. * main
  77. *******************************************************************************
  78.  
  79. _PrgMain    movea.l    DIAdr,a2    ;our display
  80.     movea.l    ILBMStrcAdr,a0    ;get ILBM structure address
  81.     movea.l    (TCS_II_GfxAdr,a0),a1    ;get address of ILBM's graphic data
  82.     move.b    (TCS_II_RGBxMode,a0),d3    ;get ILBM's RGBx mode
  83.  
  84.     movea.l    a2,a0    ;render FullRes screen
  85.     CALLTCS    CPUFRPass0    ;to make pixels visible
  86.  
  87.     moveq.l    #0,d2    ;brightness at beginning (min)
  88. .FadeIn    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  89.     movea.l    a2,a0    ;our display
  90.     move.b    d3,d0    ;RGBx mode
  91.     move.w    d2,d1    ;brightness
  92.     CALLTCS    SetRGBx    ;change palette
  93.     addq.w    #1,d2    ;increase brightness
  94.     btst.b    #6,$bfe001
  95.     beq.s    .exit    ;if LMB...
  96.     cmpi.w    #256,d2
  97.     bls.s    .FadeIn    ;repeat other 256 times
  98.  
  99.     move.w    #256,d2    ;brightness at beginning (max)
  100. .FadeOut    WTRSTLN    DSPLY0    ;wait for Copper to write the palette
  101.     movea.l    a2,a0    ;our display
  102.     move.b    d3,d0    ;RGBx mode
  103.     move.w    d2,d1    ;brightness
  104.     CALLTCS    SetRGBx    ;change palette
  105.     btst.b    #6,$bfe001    ;exit if LMB
  106.     dbeq    d2,.FadeOut    ;decrease brightness and repeat other 256 times
  107. .exit    rts
  108.  
  109.  
  110.  
  111. *******************************************************************************
  112. * cleanup
  113. *******************************************************************************
  114.  
  115. _PrgClnUp    movea.l    ILBMStrcAdr,a0    ;free all the memory
  116.     CALLTCS    UnLdILBM    ;allocated for the ILBM
  117.     rts
  118.  
  119.  
  120.  
  121. *******************************************************************************
  122. * data
  123. *******************************************************************************
  124.  
  125.     include    /includes/dat.i
  126.  
  127.     cnop    0,4
  128. ILBMStrcAdr    dc.l    0    ;ILBM structure pointer
  129. tmplt    dc.b    "ILBM/K",0    ;template for ReadArgs()
  130. PicFlNm    dc.b    "/pix/TM_rgbw.iff",0    ;default ILBM
  131.